<template>
    <input type="text" v-model="keyword">
    <h1>{{keyword}}</h1>
</template>

<script>

    import { ref, reactive, customRef } from 'vue'
    //引用对象
    export default {

        setup() {
            function myref(value, delay) {
                let timer
                return customRef((track, trigger) => {
                    return {
                        get() {
                            track()
                            return value
                        },
                        set(newvalue) {
                            clearTimeout(timer)
                            timer = setTimeout(() => {
                                value = newvalue
                                trigger();
                            }, delay)

                        }
                    }

                })

            } const keyword = myref('111', 100)
            return {
                keyword
            }
        }

    }

</script>

<style>

</style>